//
//  DBHomeWebController.swift
//  大波微博swift
//
//  Created by 大波 on 16/3/12.
//  Copyright © 2016年 zhaojin. All rights reserved.
//

import UIKit

class DBHomeWebController: UIViewController {
    
    var address: String?
    
    override func loadView() {
        
        view = webView
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        if address == nil {
            
            print("webView没地址加载不出来")
            
            return
        }
        
        let url = NSURL(string: address!)
        
        let request = NSURLRequest(URL: url!)
        
        webView.loadRequest(request)
        
        setNavigationBarItem()
    }
    
    private func setNavigationBarItem() {
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "关闭", style: UIBarButtonItemStyle.Plain, target: self, action: "close")
    }
    
    @objc private func close() {
        
        dismissViewControllerAnimated(true, completion: nil)
    }
    
    // MARK: - 懒加载
    
    private lazy var webView: UIWebView = UIWebView()
}
